package com.example.lotterysystem.common.exception;

import com.example.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created with IntelliJ IDEA.
 * Description: Controller异常类定义
 * User: Spider-Man
 * Date: 2025-08-17
 * Time: 19:48
 */
@Data
@EqualsAndHashCode(callSuper = true)
//运行时异常
public class ControllerException extends RuntimeException{
    /**
     *异常码
     * @see com.example.lotterysystem.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;
    //异常消息内容
    private String message;
    //为了序列化,序列化时是必须带一个无参的构造函数才能成功.
    public ControllerException() {

    }

    public ControllerException(Integer code,String massage) {
        this.code = code;
        this.message = massage;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
}
